//wxScan 微信扫码功能
function wxScan(url) {
  if (typeof (url) == 'undefined' || url.length < 1)
    return;
  //注册页面根据情况跳转
  if (url.indexOf('register.html') > 0) {
    setTimeout(function () {//app.js登录为异步登录，此处等待2s
      if (getApp().globalData.platUser == null) {//用户未登录 跳转至登录页面
        wx.navigateTo({
          url: '../login/login'
        });
      } else
        return;
    }, 2000);
  }
  wx.request({
    url: getApp().globalData.host + 'webapp/control/wxScan.html',
    data: { url: url },
    header: getApp().globalData.header,
    success: function (res) {
      if (typeof (res.data) != 'undefined' && res.data.length > 1) {
        wx.navigateTo({
          url: res.data,
        })
      }
    },
    fail: function (res) { },
    complete: function (res) { }
  })
}


module.exports = {
  wxScan: wxScan
}
